from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.endpoints import kb_chat, chat


app = FastAPI(
    title="LLM Application Scaffold - Separated Endpoints",
    description="An API with distinct, stateful endpoints for Knowledge Base (RAG) chat and Agent (Tool-calling) chat.",
    version="2.2.0",
)

app.include_router(kb_chat.router, prefix="/api/kb_chat", tags=["Knowledge Base Chat"])
app.include_router(chat.router, prefix="/api/chat", tags=["Agent / Tool-calling Chat"])


@app.get("/", tags=["Health Check"])
def read_root():
    return {"status": "ok", "message": "Welcome to the LLM Scaffold API!"}
# main.py（添加跨域支持）



app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],  # 开发环境允许所有来源；生产环境指定具体域名
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)